home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Freeware / Adobe Air 1.5 / AdobeAIRInstaller.exe / setup.swf / scripts / mx / states / SetProperty.as < prev    next >
Encoding:
Text File  |  2008-10-29  |  3.6 KB  |  126 lines

  1. package mx.states
  2. {
  3.    import mx.core.UIComponent;
  4.    import mx.core.mx_internal;
  5.    
  6.    use namespace mx_internal;
  7.    
  8.    public class SetProperty implements IOverride
  9.    {
  10.       mx_internal static const VERSION:String = "3.0.0.0";
  11.       
  12.       private static const PSEUDONYMS:Object = {
  13.          "width":"explicitWidth",
  14.          "height":"explicitHeight"
  15.       };
  16.       
  17.       private static const RELATED_PROPERTIES:Object = {
  18.          "explicitWidth":["percentWidth"],
  19.          "explicitHeight":["percentHeight"]
  20.       };
  21.       
  22.       private var oldRelatedValues:Array;
  23.       
  24.       private var oldValue:Object;
  25.       
  26.       public var name:String;
  27.       
  28.       public var target:Object;
  29.       
  30.       public var value:*;
  31.       
  32.       public function SetProperty(param1:Object = null, param2:String = null, param3:* = undefined)
  33.       {
  34.          super();
  35.          this.target = param1;
  36.          this.name = param2;
  37.          this.value = param3;
  38.       }
  39.       
  40.       public function remove(param1:UIComponent) : void
  41.       {
  42.          var _loc5_:int = 0;
  43.          var _loc2_:Object = !!target ? target : param1;
  44.          var _loc3_:String = !!PSEUDONYMS[name] ? PSEUDONYMS[name] : name;
  45.          var _loc4_:Array = !!RELATED_PROPERTIES[_loc3_] ? RELATED_PROPERTIES[_loc3_] : null;
  46.          if((name == "width" || name == "height") && !isNaN(Number(oldValue)))
  47.          {
  48.             _loc3_ = name;
  49.          }
  50.          setPropertyValue(_loc2_,_loc3_,oldValue,oldValue);
  51.          if(_loc4_)
  52.          {
  53.             _loc5_ = 0;
  54.             while(_loc5_ < _loc4_.length)
  55.             {
  56.                setPropertyValue(_loc2_,_loc4_[_loc5_],oldRelatedValues[_loc5_],oldRelatedValues[_loc5_]);
  57.                _loc5_++;
  58.             }
  59.          }
  60.       }
  61.       
  62.       private function toBoolean(param1:Object) : Boolean
  63.       {
  64.          if(param1 is String)
  65.          {
  66.             return param1.toLowerCase() == "true";
  67.          }
  68.          return param1 != false;
  69.       }
  70.       
  71.       public function apply(param1:UIComponent) : void
  72.       {
  73.          var _loc6_:int = 0;
  74.          var _loc2_:Object = !!target ? target : param1;
  75.          var _loc3_:String = !!PSEUDONYMS[name] ? PSEUDONYMS[name] : name;
  76.          var _loc4_:Array = !!RELATED_PROPERTIES[_loc3_] ? RELATED_PROPERTIES[_loc3_] : null;
  77.          var _loc5_:* = value;
  78.          oldValue = _loc2_[_loc3_];
  79.          if(_loc4_)
  80.          {
  81.             oldRelatedValues = [];
  82.             _loc6_ = 0;
  83.             while(_loc6_ < _loc4_.length)
  84.             {
  85.                oldRelatedValues[_loc6_] = _loc2_[_loc4_[_loc6_]];
  86.                _loc6_++;
  87.             }
  88.          }
  89.          if(name == "width" || name == "height")
  90.          {
  91.             if(_loc5_ is String && _loc5_.indexOf("%") >= 0)
  92.             {
  93.                _loc3_ = name == "width" ? "percentWidth" : "percentHeight";
  94.                _loc5_ = _loc5_.slice(0,_loc5_.indexOf("%"));
  95.             }
  96.             else
  97.             {
  98.                _loc3_ = name;
  99.             }
  100.          }
  101.          setPropertyValue(_loc2_,_loc3_,_loc5_,oldValue);
  102.       }
  103.       
  104.       public function initialize() : void
  105.       {
  106.       }
  107.       
  108.       private function setPropertyValue(param1:Object, param2:String, param3:*, param4:Object) : void
  109.       {
  110.          if(param4 is Number)
  111.          {
  112.             param1[param2] = Number(param3);
  113.          }
  114.          else if(param4 is Boolean)
  115.          {
  116.             param1[param2] = toBoolean(param3);
  117.          }
  118.          else
  119.          {
  120.             param1[param2] = param3;
  121.          }
  122.       }
  123.    }
  124. }
  125.  
  126.